﻿@using CodeCamp.Models.Sessions
@using CodeCamp.Models.Shared
@using CodeCamp.Infrastructure.Extensions
@model SessionsListViewModel
@{
    ViewBag.Title = "";
    if ((@Model != null) && (@Model.EventDisplayName != null))
    {
        ViewBag.Title = @Html.Encode(@Model.EventDisplayName + " | Sessions");
    }
    else
    {
        ViewBag.Title = "Code Camp | Sessions";
    }
}

@section headaddon {
<style>
    p.session-description
    {
        margin-top: 0;
    }
</style>
}

<h1 class="title">Sessions at @Model.EventDisplayName</h1>
<h3>@Model.EventStartDate.ToLongDateString()</h3>

@* if current event and submissions not yet closed ... *@
@if ((Model.EventShortName == Model.DefaultEventShortName) && (DateTime.Now < Model.SubmissionsCloseDate))
{
@Html.Partial("SessionTopicsListPartial")
}

@if (!Model.ScheduleIsPublic && !Model.SubmissionsOpen && (Model.SubmissionsOpenDate > DateTime.Now))
{
    <text>&nbsp;<br /></text>
    <h3>Session Submissions Open @Model.SubmissionsOpenDate.ToString("ddd, MMM dd, yyyy")</h3>
    <p>To get an idea of what to expect, check out what happened at 
        @Html.ActionLink("other Boston Code Camps", "OtherCCEvents", "Home", new { eventName = @Model.EventShortName }, null).</p>
    @*
        @Html.ActionLink("other Boston Code Camps", "About", "Home", null, null, "priorCamps", new { eventName = @Model.EventShortName }, null).</p>
    *@
}
else
{
    if (!Model.ScheduleIsPublic && (Model.EventStartDate > DateTime.Now))
    {
        <p>The following sessions have been submitted, though sessions submitted are not guaranteed to be presented.
           The final selection of sessions for the event will occur shortly after the session submission period closes
           at end of day on @Model.SubmissionsCloseDate.ToString("ddd, MMM dd") and will be published by 
            end of day on @Model.SubmissionsCloseDate.AddDays(3).ToString("ddd, MMM dd").
           Presenters will be made public at that time.
        </p>
        <p>The event organizers goal is to include a diverse selection of presenters and topics.</p>
    }

    <p>@Html.Encode(@Model.Sessions.Count) sessions.</p>
}

<div class="presentations">
@foreach (SessionViewModel session in @Model.Sessions)
{
    <div class="presentation-container">
        @Html.Partial("PartialViews/SessionTitle", new SessionTitle { SessionId = session.Id, Title = session.Title })<br />
        @Html.Partial("PartialViews/SessionTags", session.Tags)
        @if (Model.PresentersArePublic || User.IsInRole(CCRoles.RoleNames.BigCheeze) || User.IsInRole(CCRoles.RoleNames.EventContentEditor)
                || User.IsInRole(CCRoles.RoleNames.EventTrackLead))
        {
            if (!Model.PresentersArePublic)
            {
                <b>[presenter(s) not public]</b>
            }
        @Html.Partial("PartialViews/SessionPresenters", session.SessionPresenters.Presenters)
        }
        @if ((session.ScheduleInfo != null) && (Model.ScheduleIsPublic || Model.ScheduleInsider))
        {
            @Html.Partial("PartialViews/SessionScheduleInfo", session.ScheduleInfo)
        }
        <br />
        <p class="session-description">
        @if (session.Description.Length <= 400)
        {
            @Html.Raw(@Html.Encode(session.Description).Replace(Environment.NewLine, "<br/>"))
        }
        else
        {
            @Html.Raw(@Html.Encode(session.Description.TruncateWithElipses(400)).Replace(Environment.NewLine, "<br/>"))
            <text>&nbsp;</text>@Html.ActionLink("more", "Details", new { id = session.Id })
        }
        </p>
    </div>
}
</div>

@section sidebar {
    @Html.Partial("SidebarCommonPartial")

    <div id="eventTagsContainer" class="widget rounded-10">
        <h3>Event Tags</h3>
        @Html.Partial("PartialViews/EventTags", Model.EventTagsInUse )
    </div>
}
